package com.ukao.steward.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.ukao.steward.R;
import com.ukao.steward.base.ListBaseAdapter;
import com.ukao.steward.base.SuperViewHolder;
import com.ukao.steward.bean.ProductRelImgBean;
import com.ukao.steward.util.DensityUtils;
import com.ukao.steward.util.ImageUtils;

import java.util.List;

/**
 * Created by ukaodev on 2017/8/24.
 */

public class PhotoAdapter extends ListBaseAdapter<ProductRelImgBean> {




    public PhotoAdapter(Context context, List<ProductRelImgBean> mHomeBean) {
        super(context, mHomeBean);
    }

    @Override
    public int getLayoutId() {
        return R.layout.adapter_photo_item;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder,final int position) {
        ProductRelImgBean item = getItem(position);
        ImageView photo = holder.getView(R.id.photo);
        ImageView removeImage = holder.getView(R.id.remove_image);
        ImageUtils.loadImage(mContext, item.getCameraImg(), photo, R.drawable.nav_header_header);

        ViewGroup.LayoutParams mParams = holder.itemView.getLayoutParams();
        mParams.height= (DensityUtils.getScreenW()-DensityUtils.dip2px(60))/4;
        holder.itemView.setLayoutParams(mParams);
        removeImage.setOnClickListener(v -> {
                if (mOnItemChildClickListener!=null){
                    mOnItemChildClickListener.onChildItemClick(R.id.remove_image,position,getItem(position));
                }
        });

    }

}
